
 
<!--[form:email]-->
<div style="height:30px">标&nbsp;&nbsp;题:
<%= text_field 'email', 'title', :title=>"消息标题", :size=>50, :validate=>"required:true", :class=>"required dojoValidateEmpty"  %>
</div>
<div  style="height:30px">
  <% if current_user.user_type == 1%>
    <a href="javascript:show_users(this, 'users')" id="flag">收件人:</a>
    <span id="recv" width=100% style="background-color:pink">
    <% if @address && @address.size > 0 %>
      <% users = YtwgUser.find(:all, :conditions=>"id in (#{@address.join(',')})") %>
      <%= users.collect{|u| u.truename}.join(',') %>
    <% end %>
    </span>
    <%= render :partial =>"/share/user_select", :locals=>{:address=>@address, :divid=>"users", :name=>"email[user_ids][]", :accept=>"recv"} %>
  <% else%>
    收件人:<%= text_field_tag "recv", params[:recv], :title=>"收件人", :size=>50, :validate=>"required:true", :class=>"required dojoValidateEmpty"%>
  <% end %>
</div>


<%= fckeditor_textarea("email", "content",  :toolbarSet => 'Basic', :width => '97%', :height => '260px') %>
<br/>
<%= hidden_field("email", "cg")  %>


附&nbsp;&nbsp;件<br>
<%= file_column_field 'email', 'attach' %><br>
<%= file_column_field 'email', 'attach2' %><br>
<%= file_column_field 'email', 'attach3' %><br>
<!--[eoform:email]-->


<script>
    function show_users(obj, divid)
    {
        var div = $("#" + divid).get(0);
        var flag = $('#flag').get(0);
        div.style.pixelLeft = flag.offsetLeft;
        div.style.pixelTop = flag.offsetTop+35;
        $("#" + divid).slideDown("slow"); 
    }
    
    function hide_users(username, tagname, divid)
    {
        var users = document.getElementsByName(username);
        var recv = "";
        for(var i=0; i<users.length; i++)
        {
            if (users[i].checked)
            {
                if (recv.length == 0)
                    recv = users[i].text;
                else
                    recv = recv + "," + users[i].text;
            }
        }
        $("#" + tagname).text(recv);
        $("#" + divid).slideUp("slow"); 
    }
    function select_all(form, tagname)
    {
        check = document.getElementsByName("selectall"+tagname)[0];
        if (check.checked)
        {
            for(var i=0; i<form.elements.length-1; i++)
            {
                if (form.elements[i].name == tagname)
                    form.elements[i].checked = true;
            }
                                        
        }
        else
        {
            for(var i=0; i<form.elements.length-1; i++)
            {
                if (form.elements[i].name == tagname)
                    form.elements[i].checked = false;
            }
        }
    }
    
    function select_dep(departmentid)
    {
        checks = document.getElementsByTagName("INPUT");
        if ($('#'+departmentid).get(0).checked)
        {
            for(var i=0; i<checks.length-1; i++)
            {
                if (checks[i].id == "department" + departmentid)
                    checks[i].checked = true;
            }
                                        
        }
        else
        {
            for(var i=0; i<checks.length-1; i++)
            {
                if (checks[i].id == "department" + departmentid)
                    checks[i].checked = false;
            }
        }
    }

</script>
